package com.shiliu.swagger2;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @description: Swagger2 Api接口配置类
 * @author: shili
 * @created: 2019/12/17 18:30
 * @version: v1.0.0
 */
@Configuration
@EnableSwagger2
public class Swagger2Configuration {

    /**
     * 创建Api
     */
    @Bean
    public Docket docketApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.shiliu.api"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * 项目信息配置
     * @return
     */
    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("MJJ-App接口文档")
                .description("专门使用于开发App接口的项目,使用Springboot mybatis-plus等技术")
                .contact(new Contact("项目名称: MJJ-APP","http://www.shiliu16.com",""))
                .build();
    }
}
